package com.shujia.wyh.day06.homework.test4;

//商品编号，商品名称，所属类别，商品数量（大于 0），商品价格（大于 0），
public class GoodsInfo {
    private int gid;
    private String goodsName;
    private GoodsKind goodsKind;
    private int number;
    private double price;

    public GoodsInfo() {
    }

    public GoodsInfo(int gid, String goodsName, GoodsKind goodsKind, int number, double price) {
        this.gid = gid;
        this.goodsName = goodsName;
        this.goodsKind = goodsKind;
        setNumber(number);
        this.price = price;
    }

    public int getGid() {
        return gid;
    }

    public void setGid(int gid) {
        this.gid = gid;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public GoodsKind getGoodsKind() {
        return goodsKind;
    }

    public void setGoodsKind(GoodsKind goodsKind) {
        this.goodsKind = goodsKind;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        if (number > 0) {
            this.number = number;
        } else {
            System.out.println("库存数量异常，请联系管理员");
            this.number = 0;
        }
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public void show() {
        System.out.println("商品名称：" + goodsName);
        System.out.println("所属类别：" + goodsKind.getKindName());
        System.out.println("商品售价：" + price);
        System.out.println("库存数量：" + number);
        System.out.println("商品总价：" + (number * price));
    }
}
